home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / bro30_.zip / BROWSE.CLA
Text File  |  1994-05-26  |  44KB  |  650 lines

  1.                  PROGRAM
  2. OMIT('┘')
  3. ┌───────────────────────────────────────────────────────────┬────────────────┐
  4. │                                                           │Version:3007.200│
  5. ├───────────────────────────────────────────────────────────┴────────────────┤
  6. │        BROWSE.CLA - The Browse Support Module           TER 05/22 3007.200 │
  7. │                                                                            │
  8. │        This Browse Module is version 3007.200 with changes to allow 2.1    │
  9. │        type Incremental Browses.  The Mouse cannot select the Incremental  │
  10. │        Brouse field, and less than one character in an Incremental Browse  │
  11. │        field will return you to the Queue.  All changes are marked with    │
  12. │        !# TER. (The typing delay has also been shortened to react faster.) │
  13. │        Any responses should be addressed to:                               │
  14. │                         Timothy E. Rossin                                  │
  15. │                         Compuserve Address: 74072,2630                     │
  16. │                                                                            │
  17. │        The Browse Support Module manages the process of scrolling records  │
  18. │        through a list box.  Browse support is conducted in a session that  │
  19. │        is initiated by the BeginBrowse procedure and terminated by the     │
  20. │        EndBrowse procedure.  Multiple browse sessions may be conducted at  │
  21. │        the same time (e.g. a browse procedure calls a form which calls a   │
  22. │        lookup procedure).  The current status of a browse session is       │
  23. │        stored in a Session queue.  The browse process uses a position      │
  24. │        queue which contains a POSITION() string used to access displayed   │
  25. │        records.                                                            │
  26. │                                                                            │
  27. │        BeginBrowse(List,Locator,Immediate,Increment,Nomemo)                │
  28. │                                                                            │
  29. │            Initiate a browse session and append a new element to the       │
  30. │            Session queue.  Fixed (non-scrolling) queue elements should be  │
  31. │            the only elements in the list queue when a session begins.      │
  32. │                                                                            │
  33. │            "List" is the field number of a list box that displays a queue  │
  34. │            of formatted records.                                           │
  35. │                                                                            │
  36. │            "Locator" is an optional parameter that contains the field      │
  37. │            number of a locator field.  Typing any displayable character    │
  38. │            activates the locator field.  The USE variable of the locator   │
  39. │            field must be a key component, so completing the locator field  │
  40. │            scrolls the list box to the first matching record.              │
  41. │                                                                            │
  42. │            "Immediate" is an optional parameter that contains a 1 if the   │
  43. │            selected record is to be accessed each time the selector bar    │
  44. │            moves over a new record.                                        │
  45. │                                                                            │
  46. │            "Increment" is an optional parameter that contains a 1, 2, 3,   │
  47. │            or 4 to request an incremental locator field that automatically │
  48. │            locates a matching record after a pause in typing.  Increment   │
  49. │            values of 2, 3, and 4 request upper case, lower case, and       │
  50. │            capitalized locator fields.  An increment value of 1 uses the   │
  51. │            case entered by the operator.                                   │
  52. │                                                                            │
  53. │            "Nomemo" is an optional parameter that contains a 1 or 2 to     │
  54. │            disarm memo fields.  A value of 1 means that memos are not      │
  55. │            displayed in the list box.  A value of 2 means, in addition,    │
  56. │            that memos are not used as hot fields.  Memos are always        │
  57. │            retrieved for "Process Field" actions.                          │
  58. │                                                                            │
  59. │        BrowseAction(File,Key,Queue)                                        │
  60. │                                                                            │
  61. │            Manages the behavior of the list box, locator field, and hot    │
  62. │            fields.                                                         │
  63. │                                                                            │
  64. │            "File" is the FILE to be scrolled.                              │
  65. │                                                                            │
  66. │            "Key" is KEY to be used to access the file.                     │
  67. │                                                                            │
  68. │            "Queue" is the display queue, declared by the caller and used   │
  69. │            as the parameter of the FROM attribute of the list box.         │
  70. │                                                                            │
  71. │            BrowseAction returns a code requesting one of the following     │
  72. │            actions: the following actions:                                 │
  73. │                                                                            │
  74. │              Set the first record and set the last record of a limited     │
  75. │              range of consecutive records.                                 │
  76. │                                                                            │
  77. │              Reject a record by issueing GET(File,0) to dereference the    │
  78. │              record or indicate that a record is out of range by issueing  │
  79. │              NEXT(File) or PREVIOUS(File) to move the record position.     │
  80. │                                                                            │
  81. │              Format a display queue element for the current record.  The   │
  82. │              queue element will be placed in the display queue by the      │
  83. │              browse manager.                                               │
  84. │                                                                            │
  85. │              Process the record under the selector bar                     │
  86. │                                                                            │
  87. │              Process a field or key that the browse manager does not       │
  88. │              recognize.  The selected record has been accessed from the    │
  89. │              file and display queue.                                       │
  90. │                                                                            │
  91. │              Take action if there are no records to display.               │
  92. │                                                                            │
  93. │              Clear the key fields subordinate to the locator field.        │
  94. │                                                                            │
  95. │        EndBrowse                                                           │
  96. │                                                                            │
  97. │            Terminate the browse session.  Free position elements for this  │
  98. │            session from the Position queue.  Free the last element from    │
  99. │            the Session queue.                                              │
  100. │                                                                            │
  101. └────────────────────────────────────────────────────────────────────────────┘
  102.                  INCLUDE('KEYCODES.EQU')
  103.                  MAP
  104.                    BeginBrowse(SHORT,<SHORT>,<BYTE>,<BYTE>,<BYTE>)
  105.                    BrowseAction(FILE,KEY,QUEUE),BYTE
  106.                    EndBrowse
  107.                  END
  108.  
  109. Session          QUEUE                           !Browse session queue
  110. Action             BYTE                          ! Caller action
  111. Process            BYTE                          ! Internal process
  112. List               SHORT                         ! List field number
  113. Locator            SHORT                         ! Locator field number
  114. Immediate          BYTE                          ! Immediate processing flag
  115. Increment          BYTE                          ! Incremental locator flag
  116. Nomemo             BYTE                          ! No memo retrieval flag
  117. Location           STRING(40)                    ! Locator field contents
  118. Length             BYTE                          ! Locator contents length
  119. Count              BYTE                          ! List item count
  120. Fixed              BYTE                          ! Fixed list item count
  121. Item               BYTE                          ! Current item (1 to Count)
  122. Choice             BYTE                          ! Selector bar position
  123. LastChoice         BYTE                          ! Last Selector position
  124. Page               STRING(1)                     ! Current page (F,L,N,blank)
  125. FirstPage          BYTE                          ! First page request flag
  126. Base               SHORT                         ! Base for position queue
  127. Selected           STRING(256)                   ! Selected record position
  128.                  END
  129.  
  130. Position         QUEUE                           !Record position queue
  131.                    STRING(256)                   ! Record Position
  132.                  END
  133.                                                  !Caller actions
  134. NoAction         EQUATE(0)                       ! No caller action
  135. FormatQueue      EQUATE(1)                       ! Format the display queue
  136. ProcessField     EQUATE(2)                       ! Process another field
  137. NoRecords        EQUATE(3)                       ! No records to display
  138. FilterRecord     EQUATE(4)                       ! Filter a record
  139. ResetFirst       EQUATE(5)                       ! Set to first of a range
  140. ResetLast        EQUATE(6)                       ! Set to last of a range
  141. ProcessSelected  EQUATE(7)                       ! Process selected record
  142. ClearRestOfKey   EQUATE(8)                       ! Clear low fields of key
  143.  
  144.                                                  !Internal processes
  145. InitSession      EQUATE(1)                       ! Initialize browse session
  146. ProcessForward   EQUATE(2)                       ! Process records forward
  147. ProcessBackward  EQUATE(3)                       ! Process records backward
  148. ProcessSingle    EQUATE(4)                       ! Process a single record
  149. AcceptInput      EQUATE(5)                       ! Accept keyboard input
  150.  
  151. LoChar           EQUATE(32)                      !Lowest displayable char
  152. HiChar           EQUATE(127)                     !Highest displayable char
  153.  
  154.                  CODE                            !Dummy program
  155.  
  156. BeginBrowse      PROCEDURE(InList,InLocator,InImmediate,InIncrement,InNomemo)
  157.  
  158.   CODE
  159.   IF RECORDS(Session) THEN PUT(Session).         !Save any current session
  160.   CLEAR(Session)                                 !Clear the session record
  161.   Action = NoAction                              !Set no caller action
  162.   Process = InitSession                          !Initialize a browse session
  163.   List = InList                                  !Set list field number
  164.   Locator = InLocator                            !Set locator field number
  165.   Immediate = InImmediate                        !Set immediate process flag
  166.   IF Locator THEN Increment = InIncrement.       !If there is a locator field
  167.   Nomemo = InNomemo                              !Set no memo flag
  168.   Count = ROWS(List)                             !Set item count
  169.   Choice = 1                                     !Set top choice
  170.   LastChoice = 1                                 !Set top last choice
  171.   Base = RECORDS(Position)                       !Set base position
  172.   ADD(Session,RECORDS(Session)+1)                !Add the session record
  173.   RETURN                                         !Return to caller
  174.  
  175. BrowseAction     FUNCTION(File,Key,Queue)
  176.  
  177. !#Delay          EQUATE(50)                      !#TER Time delay (1/2 second)
  178. Delay            EQUATE(1)                       !#TER 05/22 Time delay (.01s)
  179. SpaceKey         EQUATE(32)                      !Space bar keycode
  180. TimeOut          LONG                            !Deadline time (.01 seconds)
  181. LocatorContents  STRING(255)                     !Locator field contents
  182.  
  183.   CODE
  184.   CASE Action                                    !Process caller's action
  185.   OF FilterRecord                                !Caller filtered the record
  186.     CASE POSITION(Key)                           ! Check callers action
  187.     OF ''                                        ! The record is rejected
  188.       IF Process = ProcessSingle                 !  And previously accepted
  189.         DELETE(Queue)                            !   Delete the queue element
  190.         GET(Position,Base+Choice-Fixed)          !   Get the position element
  191.         DELETE(Position)                         !   And delete it
  192.         Process = ProcessForward                 !   Display a new last
  193.         Item = RECORDS(Queue) + 1                !    record forward
  194.         GET(Position,RECORDS(Position))          !   Get last display record
  195.         RESET(Key,Position)                      !   Reset to last display
  196.         NEXT(File)                               !   Retrieve last record
  197.       END                                        !  End IF
  198.     OF Position                                  ! The record is accepted
  199.       Action = FormatQueue                       !  Ask caller to format
  200.       RETURN(Action)                             !  Return to caller
  201.     ELSE                                         ! The record is out of range
  202.       DISPLAY(List)                              !  Display the page
  203.       SELECT(List,Choice)                        !  Select the list box
  204.       Selected = ''                              !  Clear selected position
  205.       Process = AcceptInput                      !  Get keyboard input
  206.     END                                          ! End CASE
  207.  
  208.   OF FormatQueue                                 !Caller formatted the queue
  209.     CASE Process                                 ! Jump to current process
  210.     OF ProcessForward                            ! On forward processing
  211.       ADD(Queue,RECORDS(Queue)+1)                !  Add new last element
  212.       ADD(Position,RECORDS(Position)+1)          !  Add new last position
  213.       IF RECORDS(Queue) > Count                  !  If the page overflows
  214.         GET(Queue,Fixed+1)                       !   Get the first element
  215.         DELETE(Queue)                            !   And delete it
  216.         GET(Position,Base+1)                     !   Get the first position
  217.         DELETE(Position)                         !   And delete it
  218.       END                                        !  End IF
  219.       Item += 1                                  !  Increment current item
  220.     OF ProcessBackward                           ! On backward processing
  221.       ADD(Queue,Fixed+1)                         !  Add new first element
  222.       ADD(Position,Base+1)                       !  Add new first position
  223.       IF RECORDS(Queue) > Count                  !  If the page overflows
  224.         GET(Queue,RECORDS(Queue))                !   Get the last element
  225.         DELETE(Queue)                            !   And delete it
  226.         GET(Position,RECORDS(Position))          !   GET the last position
  227.         DELETE(Position)                         !   And delete it
  228.       END                                        !  End IF
  229.       Item -= 1                                  !  Decrement current item
  230.       IF Page = 'N' THEN Choice += 1.            ! Increment selector bar
  231.     OF ProcessSingle                             ! On a single record
  232.       PUT(Queue)                                 !  Replace the element
  233.       DISPLAY(List)                              !  Display the page
  234.       SELECT(List,Choice)                        !  Select the list box
  235.       Process = AcceptInput                      !  Get keyboard input
  236.       Selected = ''                              !  Clear selected position
  237.     END                                          ! End CASE
  238.  
  239.   OF ProcessSelected                             !Caller processed a record
  240.     Selected = POSITION(Key)                     ! Set selected position
  241.  
  242.   OF ProcessField                                ! Caller processed a field
  243.     IF Process = InitSession                     ! If we got here from Init code
  244.       Process = AcceptInput                      !  Skip internal field handling
  245.       Action = NoAction                          !  Clear ACTION
  246.       RETURN(Action)                             !  And go another time around
  247.     END                                          ! END (If we got here...)
  248.     IF FIELD() <> Locator                        ! For non-locator field
  249.       IF Increment                               !  If incremental locator
  250.         DO ClearLocator                          !   Clear locator
  251.       END                                        !  End IF
  252.       IF INRANGE(FIELD(),1,List-1)               !  From a prior field
  253.         FirstPage = 1                            !   Request the first page
  254.       END                                        !  End IF
  255.     END                                          ! End IF
  256.     IF SELECTED() = Locator AND Increment AND KEYCODE() <> TabKey !# TER 05/22
  257.       DO ClearLocator                            !# TER 05/22 If Incremental
  258.       DO FirstPage                               !# TER 05/22 Locator, don't
  259.       Action = ResetFirst                        !# TER 05/22 Allow select
  260.       RETURN(Action)                             !# TER 05/22 Unless it's
  261.     END                                          !# TER 05/22 TAB Key
  262.     IF SELECTED() = List                         ! If list field is selected
  263.       IF FirstPage                               !  If first page is requested
  264.         DO FirstPage                             !   Display the first page
  265.         Action = ResetFirst                      !   Ask caller to first
  266.         RETURN(Action)                           !    record in range
  267.       ELSIF FIELD() <> Locator                   !  From any but the locator
  268.         CASE POSITION(Key)                       !   Check the record
  269.         OF ''                                    !   If record was dereferenced
  270.           DO GetChoice                           !    Get selected record
  271.           IF POSITION(Key) = Position            !    If record is still there
  272.             Process = ProcessSingle              !     Display one record
  273.             Action = FilterRecord                !     Ask caller to filter
  274.             RETURN(Action)                       !     Return to caller
  275.           ELSE                                   !    If record was deleted
  276.             DELETE(Queue)                        !     Delete the element
  277.             DELETE(Position)                     !     Delete its position
  278.             IF RECORDS(Queue) = Fixed            !     If queue is now empty
  279.               DO LastPage                        !      Display the last page
  280.               Action = ResetLast                 !      Ask caller to reset to
  281.               RETURN(Action)                     !       last record in range
  282.             ELSE                                 !     Otherwise
  283.               Process = ProcessForward           !      Display a new
  284.               Item = RECORDS(Queue) + 1          !       last record
  285.               GET(Position,RECORDS(Position))    !      Reset to the bottom
  286.               RESET(Key,Position)                !       record displayed
  287.               NEXT(File)                         !      Read the record
  288.             END                                  !     End IF
  289.           END                                    !    End IF
  290.         OF Position                              !   If record didn't move
  291.           GET(Queue,Choice)                      !    Get display element
  292.           Action = FilterRecord                  !    Ask caller to
  293.           Process = ProcessSingle                !     filter one record
  294.           RETURN(Action)                         !    Return to caller
  295.         ELSE                                     !   If record moved
  296.           DO NewPage                             !    Display the new page
  297.         END                                      !   End CASE
  298.       END                                        !  End IF
  299.     ELSE                                         ! Else another field selected
  300.       IF FIELD() <> SELECTED()                   !  If selecting a new field
  301.         Process = AcceptInput                    !    Accept keyboard input
  302.       END                                        !  End IF
  303.     END                                          ! End IF
  304.  
  305.   OF NoRecords                                   !Caller added a record
  306.     IF SELECTED() = List                         ! And selected the list field
  307.       DO FirstPage                               !  Display the first page
  308.       Action = ResetFirst                        !  Ask caller to reset to
  309.       RETURN(Action)                             !   first record in range
  310.     END                                          ! End IF
  311.  
  312.   OF ClearRestOfKey                              !Caller cleared subfields
  313.     SELECT(Locator)                              !  Select the locator field
  314.     Process = AcceptInput                        !  Accept keyboard input
  315.   END                                            !End CASE
  316.  
  317.   LOOP                                           !Main processing loop
  318.     CASE Process                                 !Jump to current process
  319.     OF InitSession                               !Start browse session
  320.       Fixed = RECORDS(Queue)                     ! Set fixed list item count
  321.       IF List <> 1                               ! If the List is not first
  322.         Action = ProcessField                    !   Process any FIELD code
  323.         RETURN(Action)                           !   Do It!
  324.       ELSE
  325.         Process = AcceptInput                    ! Accept keyboard input
  326.       END                                        ! END (If the List...)
  327.     OF ProcessForward                            !Process records forward
  328.       IF Item <= Count                           ! If page is not full
  329.         IF Nomemo THEN NOMEMO(File).             !  Disarm unneeded memos
  330.         NEXT(File)                               !  Read the next record
  331.         IF ~ERRORCODE()                          !  If a record was found
  332.           Position = POSITION(Key)               !   Save its position
  333.           Action = FilterRecord                  !   Ask caller to filter
  334.           RETURN(Action)                         !   Return to caller
  335.         ELSE                                     !  If no record was found
  336.           IF INSTRING(Page,'FN',1,1)             !   If new page
  337.             Process = ProcessBackward            !    Display prior records
  338.             Item = Count - Item + Fixed + 1      !     from the top record
  339.             IF RECORDS(Position) > Base          !    For a partial screen
  340.               GET(Position,Base+1)               !     Get top position
  341.               RESET(Key,Position)                !     Reset to top record
  342.               PREVIOUS(File)                     !     Point to prior page
  343.               CYCLE                              !     Process backwards
  344.             ELSE                                 !    For a blank screen
  345.               SET(Key)                           !     Set to end of file
  346.               Action = ResetLast                 !     Ask caller to reset
  347.               RETURN(Action)                     !     Return to caller
  348.             END                                  !    End IF
  349.           END                                    !   End IF
  350.         END                                      !  End IF
  351.       END                                        ! End IF
  352.       DISPLAY(List)                              ! Display the page
  353.       SELECT(List,Choice)                        ! Select the list box
  354.       Selected = ''                              ! Clear selected position
  355.       Process = AcceptInput                      ! Get keyboard input
  356.  
  357.     OF ProcessBackward                           !Process records backward
  358.       IF Item >= Fixed + 1                       ! If page is not full
  359.         IF Nomemo THEN NOMEMO(File).             !  Disarm unneeded memos
  360.         PREVIOUS(File)                           !  Read the prior record
  361.         IF ~ERRORCODE()                          !  If a record was found
  362.           Position = POSITION(Key)               !   Save its position
  363.           Action = FilterRecord                  !   Ask caller to filter
  364.           RETURN(Action)                         !   Return to caller
  365.         END                                      !  End IF
  366.       END                                        ! If page is full
  367.       DISPLAY(List)                              !  Display the page
  368.       SELECT(List,Choice)                        !  Select the list box
  369.       Selected = ''                              !  Clear selected position
  370.       Process = AcceptInput                      !  Get keyboard input
  371.  
  372.     OF AcceptInput                               !Get keyboard input
  373.       IF SELECTED() = List                       ! If the list box is selected
  374.         IF RECORDS(Queue) = Fixed                !  If there are no records
  375.           CASE Page                              !   Jump to current page
  376.           OF 'F'                                 !   On the first page
  377.             GET(File,0)                          !    Clear the current record
  378.             Action = NoRecords                   !    Ask caller for records
  379.           OF 'N'                                 !   On a new page
  380.             DO LastPage                          !    Display the last page
  381.             Action = ResetLast                   !    Ask for last record
  382.           ELSE                                   !   On any other page
  383.             DO FirstPage                         !    Display the first page
  384.             Action = ResetFirst                  !    Ask for first record
  385.           END                                    !   End CASE
  386.           RETURN(Action)                         !   Return to caller
  387.         END                                      !  End IF
  388.  
  389.         IF Immediate                             ! For immediate processing
  390.           GET(Position,Base+CHOICE(List)-Fixed)  !  Get selected position
  391.           IF Selected <> Position                !  If selector moved
  392.             GET(Position,Base+Choice-Fixed)      !   Get selected position
  393.             RESET(Key,Position)                  !   Reset to that record
  394.             IF Nomemo = 2 THEN NOMEMO(File).     !   Disarm unneeded memos
  395.             NEXT(File)                           !   Read the record
  396.             IF Position = POSITION(Key)          !   If record is there
  397.               Action = ProcessSelected           !    Ask to process record
  398.               RETURN(Action)                     !    Return to caller
  399.             ELSE                                 !   Else
  400.               DO NewPage                         !    Rebuild the Queue
  401.               Action = ProcessField              !    Ask to process record
  402.               RETURN(Action)                     !    Return to caller
  403.             END                                  !   End IF
  404.           END                                    !  End IF
  405.         END                                      ! End IF
  406.         IF Locator                               ! If there is a locator field
  407.           ERASE(Locator)                         !  Erase locator contents
  408.           IF Increment                           !  For incremental locator
  409.             DO ShowLocator                       !   Show locator field
  410.           END                                    !  End IF
  411.         END                                      ! End IF
  412.         LastChoice = CHOICE(List)                ! Save selector position
  413.       END                                        !End IF
  414.       ACCEPT                                     !Enable the keyboard
  415.       CASE FIELD()                               !Jump to field edit routine
  416.  
  417.       OF Locator                                 !Process the locator field
  418.         IF CONTENTS(Locator)                     ! If locator is requested
  419.           IF Increment                           !  If incremental locator
  420.             Location = CONTENTS(Locator)         !   Save location
  421.             Length = LEN(CLIP(Location))         !   Save location length
  422.           END                                    !  End IF
  423.           SELECT(List)                           !  Select the list box
  424.           DO NewPage                             !  Display a new page
  425.           Action = ProcessField                  !  Ask caller to process
  426.           RETURN(Action)                         !  Return to caller
  427.         ELSE                                     ! ELSE (If No Locator)
  428.           Action = ProcessField                  !  Ask caller to process
  429.           RETURN(Action)                         !  Return to caller
  430.         END                                      ! End IF
  431.  
  432.       OF List                                    !Process the list field
  433.         Choice = CHOICE(List)                    ! Save selector bar position
  434.         IF SELECTED() <> List                    ! Process any new fields
  435.           IF SELECTED() <> Locator               !  IF not locating
  436.             DO GetChoice                         !   Get the highlighted record
  437.           END                                    !  END (IF not locating)
  438.           Action = ProcessField                  !  Ask caller to process
  439.           RETURN(Action)                         !  Return to caller
  440.         END                                      ! END (Process...)
  441.         CASE KEYCODE()                           ! Jump to key edit routine
  442.  
  443.         OF LoChar TO HiChar                      ! For any locator character
  444.         OROF BSKey OROF SpaceKey                 ! Or a backspace or space
  445.           IF Locator                             !  If there is a locator
  446.             IF Increment                         !   On incremental locator
  447.               DO GatherKeys                      !    Gather keystrokes
  448.               IF Location                        !    If not blank
  449.                 PRESS(SUB(Location,1,Length))    !     Press the string
  450.                 PRESS(DownKey)                   !     Complete the field
  451.                 SELECT(Locator)                  !     Select locator
  452.               ELSE                               !# TER 05/22 Else less than
  453.                 Action = ResetFirst              !# TER 05/22 One, so return
  454.                 RETURN(Action)                   !# TER 05/22 With Action
  455.               END                                !    End IF
  456.             ELSE                                 !   On standard locator
  457.               PRESS(KEYCODE())                   !    Press in the keycode
  458.               SELECT(Locator)                    !    Select locator field
  459.             END                                  !   End IF
  460.             Action = ClearRestOfKey              !    Ask caller to clear
  461.             RETURN(Action)                       !     subordinate fields
  462.           END                                    !  End IF
  463.  
  464.         OF CtrlPgUp                              ! Process the Ctrl-PgUp key
  465.           DO FirstPage                           !  Display the first page
  466.           IF Increment                           !  If incremental locator
  467.             DO ClearLocator                      !   Clear locator field
  468.           END                                    !  End IF
  469.           Action = ResetFirst                    !  Ask caller to reset to
  470.           RETURN(Action)                         !   first record in range
  471.  
  472.         OF PgUpKey                               ! Process the PgUp key
  473.           IF LastChoice <> Fixed + 1             !  If not at the top
  474.             Choice = Fixed + 1                   !   Selector bar to top
  475.           ELSE                                   !  From the top
  476.             Page = ''                            !   Clear page flag
  477.             Process = ProcessBackward            !   Display a new page
  478.             Item = Count                         !    of records backward
  479.             GET(Position,Base+1)                 !   Reset to the top
  480.             RESET(Key,Position)                  !    record displayed
  481.             PREVIOUS(File)                       !   Point to prior record
  482.           END                                    !  End IF
  483.  
  484.         OF UpKey                                 ! Process the up arrow
  485.           IF LastChoice = Fixed + 1              !  From the top line
  486.             Page = ''                            !   Clear page flag
  487.             Process = ProcessBackward            !   Display a single
  488.             Item = Fixed + 1                     !    record backward
  489.             GET(Position,Base+1)                 !   Reset to the top
  490.             RESET(Key,Position)                  !    record displayed
  491.             PREVIOUS(File)                       !   Point to prior record
  492.           END                                    !  End IF
  493.  
  494.         OF DownKey                               ! Process the down arrow
  495.           IF LastChoice = Count                  !  From the bottom line
  496.             Page = ''                            !   Clear page flag
  497.             Process = ProcessForward             !   Display a single
  498.             Item = Count                         !    record forward
  499.             GET(Position,RECORDS(Position))      !   Reset to the bottom
  500.             RESET(Key,Position)                  !    record displayed
  501.             NEXT(File)                           !   Point to the next record
  502.           END                                    !  End IF
  503.  
  504.         OF PgDnKey                               ! Process the PgDn key
  505.           IF LastChoice <> Count                 !  If not at the bottom
  506.             Choice = Count                       !   Selector bar to bottom
  507.           ELSE                                   !  From the bottom
  508.             Page = ''                            !   Clear page flag
  509.             Process = ProcessForward             !   Display a new page
  510.             Item = 1 + Fixed                     !    of records forwards
  511.             GET(Position,RECORDS(Position))      !   Reset to the bottom
  512.             RESET(Key,Position)                  !    record displayed
  513.             NEXT(File)                           !   Point to the next record
  514.           END                                    !  End IF
  515.  
  516.         OF CtrlPgDn                              ! Process the Ctrl-PgDn Key
  517.           DO LastPage                            !  Display the last page
  518.           IF Increment                           !  If incremental locator
  519.             DO ClearLocator                      !   Clear locator field
  520.           END                                    !  End IF
  521.           Action = ResetLast                     !  Ask caller to reset to
  522.           RETURN(Action)                         !   last record in range
  523.  
  524.         OF   LeftKey                             ! For left arrow key,
  525.         OROF Rightkey                            ! Or right arrow key,
  526.         OROF Homekey                             ! Or Home key,
  527.         OROF Endkey                              ! Or End key,
  528.         OROF MouseLeft                           ! Or a mouse click
  529.                                                  !  Don't do anything
  530.           IF Increment                           !#TER If incremental locator
  531.             DO ClearLocator                      !#TER Clear locator field
  532.           END                                    !#TER End IF
  533.         ELSE                                     ! For any other key
  534.           DO GetChoice                           !  Get selected record
  535.           Action = ProcessField                  !  Ask caller to process
  536.           RETURN(Action)                         !  Return to caller
  537.  
  538.         END                                      ! End CASE KEYCODE()
  539.         IF Increment                             ! If incremental locator
  540.           DO ClearLocator                        !  Clear locator field
  541.         END                                      ! End
  542.       ELSE                                       ! Process any other field
  543.         IF FIELD() >= List OR FIELD() < 0        !  If not list or setup fld
  544.           DO GetChoice                           !   Get selected record
  545.         ELSIF SELECTED() = List and ~FIELD()     ! Else if reprocessing List
  546.           DO GetChoice                           !   Get selected record
  547.         END                                      !  End IF
  548.         Action = ProcessField                    !  Ask caller to process
  549.         RETURN(Action)                           !  Return to caller
  550.       END                                        ! End CASE FIELD()
  551.     END                                          !End CASE BrowseProcess
  552.   END                                            !End LOOP
  553.  
  554. GetChoice ROUTINE                                !Get selected record
  555.   GET(Queue,Choice)                              ! Get selected element
  556.   GET(Position,Base+Choice-Fixed)                ! Get selected position
  557.   RESET(Key,Position)                            ! Reset to that record
  558.   NEXT(File)                                     ! Read the record
  559.  
  560. FirstPage ROUTINE                                !Display first page
  561.   FirstPage = 0                                  ! Clear first page request
  562.   Page = 'F'                                     ! Set first page flag
  563.   DO DeletePage                                  ! Delete the old page
  564.   Choice = Fixed + 1                             ! Reset selector bar
  565.   Process = ProcessForward                       ! Display a new page
  566.   Item = Fixed + 1                               !  of records forward
  567.   SET(Key)                                       ! Set to the first record
  568.  
  569. LastPage ROUTINE                                 !Display last page
  570.   Page = 'L'                                     ! Set last page flag
  571.   DO DeletePage                                  ! Delete the old page
  572.   Choice = Count                                 ! Reset selector bar
  573.   Process = ProcessBackward                      ! Display a new page
  574.   Item = Count                                   !  of records backward
  575.   SET(Key)                                       ! Set to the last record
  576.  
  577. NewPage ROUTINE                                  !Display a new page
  578.   Page = 'N'                                     ! Set new page flag
  579.   DO DeletePage                                  ! Delete the old page
  580.   SET(Key,Key)                                   ! Set to the new record
  581.   Choice = Fixed + 1                             ! Selector bar to top
  582.   Process = ProcessForward                       ! Display a new page
  583.   Item = Fixed + 1                               !  of records forward
  584.  
  585. DeletePage ROUTINE                               !Delete the current page
  586.   LOOP WHILE RECORDS(Queue) > Fixed              ! Delete all queue
  587.     GET(Queue,RECORDS(Queue))                    !  elements after the
  588.     DELETE(Queue)                                !   fixed elements
  589.   END                                            ! End LOOP
  590.   LOOP WHILE RECORDS(Position) > Base            ! Delete all position
  591.     GET(Position,RECORDS(Position))              !  elements after the
  592.     DELETE(Position)                             !   base position
  593.   END                                            ! End LOOP
  594.  
  595. GatherKeys ROUTINE                               !Gather locator keystrokes
  596.   DO AppendKey                                   ! Append pending keystroke
  597.   TimeOut = CLOCK() + Delay                      ! Set the time delay
  598.   LOOP UNTIL CLOCK() > TimeOut                   ! Loop until time out
  599.     IF KEYBOARD()                                !  If there is a keystroke
  600.       ASK                                        !   Read the keystroke
  601.       DO AppendKey                               !   Append the keystroke
  602.       DO ShowLocator                             !   Show the user
  603.       TimeOut = CLOCK() + Delay                  !   Reset the time delay
  604.     END                                          !  End IF
  605.   END                                            ! End LOOP
  606.  
  607. AppendKey ROUTINE                                !Append keystroke to locator
  608.   CASE KEYCODE()                                 ! Process the keystroke
  609.   OF LoChar TO HiChar OROF SpaceKey              ! For a character
  610.     IF Length < COLS(Locator)                    !  If it will fit
  611.       Location = SUB(Location,1,Length) & CHR(KEYCODE()) ! Add it on
  612.       Length += 1                                !  Increment the length
  613.     END                                          !  End IF
  614.   OF BSKey                                       ! For a backspace
  615.     IF Length > 0                                !# TER  Decrement the length
  616.       Length -= 1                                !# TER 05/22
  617.     ELSE                                         !# TER 05/22
  618.       Action = ResetFirst                        !# TER 05/22
  619.       RETURN(Action)                             !# TER 05/22
  620.     END                                          !# TER 05/22
  621.     Location = SUB(Location,1,Length)            !  Shorten the string
  622.     EXECUTE Increment - 1                        !  For locator case
  623.       Location = UPPER(Location)                 !   Upper case location
  624.       Location = LOWER(Location)                 !   Lower case location
  625.       Location = UPPER(SUB(Location,1,1)) |      !   Capitalize location
  626.                & LOWER(SUB(Location,2,SIZE(Location)-1))
  627.     END                                          !  End EXECUTE
  628.   END                                            ! End CASE
  629.  
  630. ClearLocator ROUTINE                             !Clear locator field
  631.   Location = ''                                  ! Clear field string
  632.   Length = 0                                     ! Zero field length
  633.   DO ShowLocator                                 ! Show locator field
  634.  
  635. ShowLocator ROUTINE                              !Show locator field contents
  636.   SHOW(ROW(Locator),COL(Locator),SUB(Location,1,COLS(Locator)))
  637.  
  638. EndBrowse        PROCEDURE
  639.  
  640.   CODE
  641.   LOOP WHILE RECORDS(Position) > Base            !Delete all position
  642.     GET(Position,RECORDS(Position))              ! elements after the
  643.     DELETE(Position)                             !  base position
  644.   END                                            !End LOOP
  645.   DELETE(Session)                                !Delete the current session
  646.   IF RECORDS(Session)                            !For any prior session
  647.     GET(Session,RECORDS(Session))                ! Get the session element
  648.   END                                            !End IF
  649.   RETURN                                         !Return to caller
  650.